<!-- 公司sop配置 -->
<template>
  <dt-modal-edit ref="edit" title="扣分节点设置" :width="800" :loading="loading" @ok="onOk">
    <div class="taskInfo">
      <span>任务名称：</span>
      <span>{{ currentRow.sopName }}</span>
    </div>
    <div class="taskBj">
      <p>
        对应“审批流”：
        {{ currentRow.processName ? currentRow.processName : '暂无' }}
      </p>
      <p style="margin-left: 150px">
        “审批流”对应组织范围：
        {{ currentRow.multiOrgName ? currentRow.multiOrgName : '暂无' }}
      </p>
    </div>
    <p class="taskBj">
      对应驳回节点：
      {{ currentRow.leaderMsg ? currentRow.leaderMsg : '暂无' }}
    </p>
    <div class="tips">
      <Icon type="md-alert" class="tips_icon" />
      提示：您可将“审批流程”中的“流程节点”设置为“扣分”节点。设置后，任何触发节点产生驳回，对应“责任人”均将扣分
    </div>
    <dt-grid ref="table" :list="deductList" :height="400" />
  </dt-modal-edit>
</template>

<script>
  import sopApi from '@/biz/buildingManagement/sopConfig'
  import columnOpt from '../opt/deduct'
  export default {
    data() {
      return {
        currentRow: {},
        deductList: [],
        columns: [],
        loading: false
      }
    },
    methods: {
      // 列表数据
      getDeductList() {
        let params = {
          pointId: this.currentRow.pointId
        }
        sopApi
          .getDeductPointsList(params)
          .then((res) => {
            this.deductList = res
            this.$refs.edit.show()
          })
          .catch((err) => {})
      },

      show(data) {
        this.$refs.table.init(this, new columnOpt(this))
        this.currentRow = data
        if (this.currentRow.pointId) {
          this.getDeductList()
        }
      },
      onOk() {
        this.loading = true
        let nodeOrderList = []

        this.deductList.forEach(item=>{
          if(item.deduct){
            nodeOrderList.push(item.nodeOrder)
          }
        })

        let params = {
          nodeOrderList: nodeOrderList,
          pointId: this.currentRow.pointId
        }
        sopApi
          .setDeductPointsFun(params)
          .then((res) => {
            this.$refs.edit.hide()
            this.loading = false
            this.$emit('onSearch')
            this.$Message.success('设置成功')
          })
          .catch((err) => {
            this.loading = false
          })
      },
      // 处理扣分节点
      editNode(row) {
        row.deduct = !row.deduct
        this.$refs.table.loadList(this.deductList)
      }
    }
  }
</script>
<style lang="scss" scoped>
  .taskInfo {
    display: flex;
    flex-wrap: wrap;
    font-size: 16px;
  }

  .taskBj {
    display: flex;
    flex-direction: row;
    margin: 10px 0 10px 20px;

    p {
      span {
        color: #0f42a7;
        cursor: pointer;
      }
    }
  }

  .tips {
    padding: 5px 10px;
    text-align: right;
    line-height: 32px;
    font-size: 14px;
    background: rgba(254, 252, 236, 1);

    .tips_icon {
      font-size: 20px;
      color: #0f42a7;
      vertical-align: sub;
    }
  }
</style>
